import pygame
import math

class Player (pygame.sprite.Sprite):
    playerPos = [100,100]
    newPos = [100,100]
    
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        self.image = pygame.image.load("resources/images/dude.png").convert_alpha()
        self.rect = self.image.get_clip()
       
    def update(self):
        mousePos = pygame.mouse.get_pos()
        angle = math.atan2(mousePos[1]-(self.playerPos[1]),mousePos[0]-(self.playerPos[0]))
        playerrot = pygame.transform.rotate(self.image, 360-angle*57.29)
        window = pygame.display.get_surface()
        self.newPos = (self.playerPos[0]-playerrot.get_rect().width/2, self.playerPos[1]-playerrot.get_rect().height/2)
        window.blit(playerrot, self.newPos)
    
